package com.starblink.basic.style.view.recyclerview

import android.content.Context
import com.google.android.flexbox.FlexLine
import com.google.android.flexbox.FlexboxLayoutManager


class MaxLineFlexboxLayoutManager(context: Context): FlexboxLayoutManager(context) {
    private var maxLines = NOT_SET

    override fun setMaxLine(maxLine: Int) {
        maxLines = maxLine
    }

    override fun getMaxLine(): Int {
        return super.getMaxLine()
    }

    fun getMaxLines(): Int {
        return maxLines
    }


    override fun getFlexLinesInternal(): MutableList<FlexLine> {
        val flexLines = super.getFlexLinesInternal()
        val size = flexLines.size
        if (maxLines > 0 && size > maxLines) {
            flexLines.subList(maxLines, size).clear()
        }
        return flexLines
    }
}